<%--
  Created by IntelliJ IDEA.
  User: ttt
  Date: 2018/6/11
  Time: 15:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
    <script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<button onclick="f1()">发送并接收json数据</button>
</body>
<script>
    function f1() {
        $.ajax({
            url: "/json",//路径
            type: "post",//请求方式
            data: '{"brand":"apple","model":"Hsdqww2132-232","price":399.9}',
            //请求的参数
            contentType: "application/json",//发送的数据类型指定为json,与上面为一组
            dataType: "json",//接受数据的类型,与下面为一组
            success: function (data) {
                console.log(data.brand);//接受/json过来的数据
            }
        });
    }
</script>
</html>
